<template>
  <div class="body">
    <div class="title">
      <h2>地址管理</h2>
      <div class="back" @click="back"><img src="../../assets/back.png" alt=""></div>
    </div>
    <div class="list">
      <div v-for="(v,k) in data">
        <AddressList :vdata="v"></AddressList>
      </div>
    </div>
    <div class="add">
      <router-link :to="{path:'/addaddress'}"><button>添加地址</button></router-link>
    </div>
  </div>
</template>

<script>
  import {setCookie,getCookie,delCookie} from '../../cookie.js'
  import AddressList from "./AddressList"
    export default {
        name: "",
        components:{
          AddressList,
        },
        data:function(){
          return{
            data:"",
          }
        },
      created:function(){
        var params = new URLSearchParams();
        params.append('username',getCookie("username"));
        this.$http.post('/api/putian/personmess/address.php',params).then(res=>{
          console.log(res);
          this.data=res.data;
        }).catch(err=>{
          console.log(err);
        })
      },
      methods:{
          back(){
            this.$router.go(-1);
          },
      }
    }
</script>

<style scoped>
  .body{
    position: relative;
    z-index: 200;
    width: 100%;
    min-height: 100%;
    background-color: white;
  }
  .back{
    position: absolute;
    width: 60px;top: 12px;
    left: 20px;
  }
  .title{
    position: fixed;
    z-index:10;
    top: 0;
    right: 0;
    left:0;
    border-bottom: 2px solid #f0f0f0;
    width: 100%;
    margin: 0 auto;
    background-color: white;
  }
  h2{
    margin: 0;
    font-size: 36px;
    line-height: 92px;
    height: 92px;
    box-sizing: border-box;
    width: 100%;
    padding: 0 130px;
    text-align: center;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .list{
    padding-top: 92px;
  }
  .add{
    padding: 0 40px;
    margin-top: 20px;
    padding-bottom: 200px;
  }
  button{
    width: 100%;
    color: #fff;
    background-color: #009c4c;
    font-size: 32px;
    line-height: 80px;
    border-radius: 8px;
  }
</style>
